home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Util / Commodities / DFA-25.lha / DFA-25 / Archive / DFA.lha / Rexx / insert_texadr.ced < prev    next >
Text File  |  1995-05-25  |  3KB  |  141 lines

  1. /* $Revision Header built automatically *************** (do not edit) ************
  2. **
  3. ** © Copyright by Dirk Federlein
  4. **
  5. ** File             : insert_texadr.ced
  6. ** Created on       : Monday, 04.04.94 17:58:39
  7. ** Created by       : Dirk Federlein
  8. ** Current revision : V2.0
  9. **
  10. **
  11. ** Purpose
  12. ** -------
  13. **
  14. ** Inserts the address of the "person" under the cursor and
  15. ** ends up each line with a "\\" for linebreak.
  16. ** You must have DFA running to use this skript.
  17. **
  18. ** -------------------------------------------------------------------------
  19. **
  20. ** Lookup part taken from:
  21. **
  22. ** LookUp.ced                        Copyright (c) 1989, Peter Cherna
  23. **
  24. ** ARexx program for CygnusEd Professional that looks up the word under
  25. ** the cursor.
  26. **
  27. ** Version 1.30:  August 20, 1989    Release 1.2:  August 29, 1989
  28. **
  29. ** -------------------------------------------------------------------------
  30. **
  31. ** Revision V2.0
  32. ** --------------
  33. ** created on Monday, 04.04.94 17:58:39  by  Dirk Federlein.   LogMessage :
  34. **     --- Initial release ---
  35. **
  36. *********************************************************************************/
  37.  
  38. options results
  39.  
  40. address 'rexx_ced'
  41.  
  42. tabchar = '09'X
  43. cr    = '0A'X
  44. /*    Get contents of current line: */
  45. status 55
  46. line = result
  47.  
  48. /*    Get tab size: */
  49. status 8
  50. tabadjust = result - 1
  51.  
  52. /*    Get cursor x position (relative to beginning of line = 1): */
  53. status 46
  54. cur = result + 1
  55.  
  56. i = index(line,tabchar)
  57. DO while i > 0 & i <= cur - tabadjust
  58.     cur = cur - tabadjust
  59.     i = index(line,tabchar,i+1)
  60. END
  61.  
  62. /*    If the current character is non-alphabetic, then start one character
  63.     over to the left.  This allows the cursor to be immediately after
  64.     the key word (say on a space or bracket.) */
  65.  
  66. char = substr(line,cur,1)
  67. if (~(datatype(char,'A') | char = '_') & cur > 1) then
  68.     cur = cur - 1
  69.  
  70. /*    Find leftmost and rightmost alphabetic character adjacent to current: */
  71.  
  72. right = cur - 1
  73. left = cur + 1
  74. char = 'A'
  75. DO while (datatype(char,'A') | char = '_') & (left > 0)
  76.      left = left - 1
  77.     if left > 0 then
  78.         char = substr(line,left,1)
  79. END
  80. char = 'A'
  81. DO while (datatype(char,'A') | (char = '_'))
  82.     right = right + 1
  83.     char = substr(line,right,1)
  84. END
  85.  
  86. if right-left <= 1 then
  87. DO
  88.     getstring
  89.     target = result
  90.     if (target = 'RESULT') then
  91.         exit
  92. END
  93. else
  94. DO
  95.     target = substr(line,left+1,right-left-1)
  96.     newtarget = '#?'target'#?'
  97. END
  98.  
  99. DO
  100.     say 'Searching for address' newtarget '...'
  101.  
  102.     if ~show(ports, DFA) then
  103.     do
  104.         'okay1' 'You should have DFA running, if you' cr 'want to get an address from it!'
  105.         exit 0
  106.     end
  107.  
  108.     address 'DFA' "SEARCH" newtarget "IGNORECASE ALL STEM ADR."
  109.  
  110.     "Prev WORD"
  111.     "Mark BLOCK"
  112.     "NEXT WORD"
  113.     "CUT BLOCK"
  114.  
  115.     if rc=0 then
  116.     do
  117.         text ADR.ADDRESS.0
  118.         text "\\"
  119.         text cr
  120.         text ADR.ADDRESS.1
  121.         text " "
  122.         text ADR.ADDRESS.2
  123.         text "\\"
  124.         text cr
  125.         text ADR.ADDRESS.4
  126.         text "\\"
  127.         text cr
  128.         text ADR.ADDRESS.5
  129.         text " "
  130.         text ADR.ADDRESS.6
  131.         text "\\"
  132.         text cr
  133.         text ADR.ADDRESS.8
  134.         text " "
  135.     end
  136.     else
  137.         'okay1' 'Could not find address of' newtarget '! '
  138.     END
  139.  
  140. exit
  141.